package com.jt.zcdemo.order;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.C;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/1/22 20:19
 */
@Component
@Slf4j
public class OrderInfoServiceImpl  {

    @Resource
    private JdbcTemplate jdbcTemplate;


    @Async
    public void getOrderInfo() {
        while (true) {

            //"            left join safe_alarm_deal_2024_12 s on t.carNum=s.carNum and t.alarmTagHex=s.alarmTagHex\n" +
            String sql = "SELECT count(1) total,t.carName,t.alarmName from safe_alarm_2024_12_copy1 t\n" +
                    //"            left join safe_alarm_deal_2024_12 s on t.carNum=s.carNum and t.alarmTagHex=s.alarmTagHex\n" +
                    "         WHERE " +
                    //"s.is_statis=1\n" +
                    //"             and " +
                    "t.carName in (\n" +
                    "                '鲁EE0990'\n" +
                    "            ,\n" +
                    "                '鲁EG6385'\n" +
                    "            ,\n" +
                    "                '鲁EE0355'\n" +
                    "            ,\n" +
                    "                '鲁EE3900'\n" +
                    "            ,\n" +
                    "                '鲁EE3709'\n" +
                    "            ,\n" +
                    "                '鲁EE3908'\n" +
                    "            ,\n" +
                    "                '鲁EJ1829'\n" +
                    "            ,\n" +
                    "                '鲁EF8319'\n" +
                    "            ,\n" +
                    "                '鲁EC2013'\n" +
                    "            ,\n" +
                    "                '鲁EE3675'\n" +
                    "            ,\n" +
                    "                '鲁EG6033'\n" +
                    "            ,\n" +
                    "                '鲁EG6791'\n" +
                    "            ,\n" +
                    "                '鲁EF7083'\n" +
                    "            ,\n" +
                    "                '鲁EE1733'\n" +
                    "            ,\n" +
                    "                '鲁EE3359'\n" +
                    "            ,\n" +
                    "                '鲁EE0920'\n" +
                    "            ,\n" +
                    "                '鲁EE0927'\n" +
                    "            ,\n" +
                    "                '鲁EK3971'\n" +
                    "            ,\n" +
                    "                '鲁EF6900'\n" +
                    "            ,\n" +
                    "                '鲁EF0290'\n" +
                    "            ,\n" +
                    "                '鲁EF9738'\n" +
                    "            ,\n" +
                    "                '鲁EF6506'\n" +
                    "            ,\n" +
                    "                '鲁EG5775'\n" +
                    "            ,\n" +
                    "                '鲁EE2199'\n" +
                    "            ,\n" +
                    "                '鲁EE0299'\n" +
                    "            ,\n" +
                    "                '鲁EE0895'\n" +
                    "            ,\n" +
                    "                '鲁EF7212'\n" +
                    "            ,\n" +
                    "                '鲁EH5232'\n" +
                    "            ,\n" +
                    "                '鲁EF0892'\n" +
                    "            ,\n" +
                    "                '鲁EE3809'\n" +
                    "            ,\n" +
                    "                '鲁EN5865'\n" +
                    "            ,\n" +
                    "                '鲁EF8302'\n" +
                    "            ,\n" +
                    "                '鲁EF7299'\n" +
                    "            ,\n" +
                    "                '鲁EF9625'\n" +
                    "            ,\n" +
                    "                '鲁EK2891'\n" +
                    "            ,\n" +
                    "                '鲁EF1390'\n" +
                    "            ,\n" +
                    "                '鲁EG7183'\n" +
                    "            ,\n" +
                    "                '鲁EE3096'\n" +
                    "            ,\n" +
                    "                '鲁EG3568'\n" +
                    "            ,\n" +
                    "                '鲁EK9326'\n" +
                    "            ,\n" +
                    "                '鲁EL9722'\n" +
                    "            ,\n" +
                    "                '鲁EF2805'\n" +
                    "            ,\n" +
                    "                '鲁EC2537'\n" +
                    "            ,\n" +
                    "                '鲁EL3981'\n" +
                    "            ,\n" +
                    "                '鲁EE3733'\n" +
                    "            ,\n" +
                    "                '鲁EA0521'\n" +
                    "            ,\n" +
                    "                '鲁EE3937'\n" +
                    "            ,\n" +
                    "                '鲁EE0900'\n" +
                    "            ,\n" +
                    "                '鲁EG7609'\n" +
                    "            ,\n" +
                    "                '鲁EF5283'\n" +
                    "            ,\n" +
                    "                '鲁EG2807'\n" +
                    "            ,\n" +
                    "                '鲁EF9762'\n" +
                    "            ,\n" +
                    "                '鲁EF5630'\n" +
                    "            ,\n" +
                    "                '鲁EG2528'\n" +
                    "            ,\n" +
                    "                '鲁EM9287'\n" +
                    "            ,\n" +
                    "                '鲁EG2129'\n" +
                    "            ,\n" +
                    "                '鲁EF8629'\n" +
                    "            ,\n" +
                    "                '鲁EG5837'\n" +
                    "            ,\n" +
                    "                '鲁EE6055'\n" +
                    "            ,\n" +
                    "                '鲁EH7291'\n" +
                    "            ,\n" +
                    "                '鲁EE3583'\n" +
                    "            ,\n" +
                    "                '鲁EG3298'\n" +
                    "            )\n" +
                    "            \n" +
                    "                and t.alarmTime >= '2024-12-01 00:00:00'\n" +
                    "            \n" +
                    "            \n" +
                    "                and t.alarmTime <= '2024-12-31 23:59:59' \n" +
                    "        group by t.carName,alarmName\n" +
                    "        order by carName";

            TimeInterval timer = DateUtil.timer();

            log.info(jdbcTemplate.queryForList(sql).toString());


            log.info("耗时：{}", timer.intervalMs());
        }
    }


    public void insert(){
        String sql = "INSERT   into safe_alarm_2024_12_copy1 (carName,carNum,alarmName,alarmType,safeProtocol,alarmTagHex,alarmTime,lng,lat,picUrl,vidUrl,addr,speed,drct,vehicleTeamNum,vehicleTeamName,companyNum,districtNum,driverName) VALUES ('鲁EM3126','鲁EM312690163','车道偏离','6','jiangsu','41303533393443250122212241000300','2024-12-22 21:22:42','117.381524','38.390146','','','河北省,沧州市,黄骅市,G18-长深高速公路上或附近','67.0','336','ff80808184f5b467018503e44ec20dbe','东营中润道路运输有限公司车队'," +
                "'ff80808" + IdUtil.simpleUUID()+
                "','370521','张爱良')";
        TimeInterval timer = DateUtil.timer();
        jdbcTemplate.execute(sql);
        log.info("插入数据耗时：{}", timer.intervalMs());
    }
}
